package xiaohu.day6.HJ63;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            String str = scanner.nextLine();
            int n = Integer.valueOf(scanner.nextLine());

            int max = 0;
            int index = 0;
            for (int i = 0; i < str.length() - n; i++) {
                int count = 0;
                for (int j = i; j < i+n; j++) {
                    if (str.charAt(j) == 'G' || str.charAt(j) == 'C') {
                        count++;
                    }
                }
                if (count > max) {
                    max = count;
                    index = i;
                }
            }
            System.out.println(str.substring(index, index + n));
        }
    }
}
